home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 …ember: Reference Library / Dev.CD Dec 97 RL.toast / What's New / Tool Chest / Testing & Debugging / Virtual User / Examples / External Tool Templates / CPlus Tool Template / List.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-15  |  2.2 KB  |  91 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    File:        List.h
  3.  *
  4.  *    Contains:    xxx put contents here xxx
  5.  *
  6.  *    Written by:    Rick Violet
  7.  *
  8.  *    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  9.  *
  10.  *    Change History (most recent first):
  11.  *
  12.  *                11/18/92    RV        xxx put comment here xxx
  13.  *
  14.  *    To Do:
  15.  */
  16.  
  17. #ifndef __LIST__
  18. #define __LIST__
  19.  
  20. #ifndef __Object__
  21. #include     "Object.h"
  22. #endif
  23.  
  24. class    ListNode;
  25. class    List;
  26. class    Loop;
  27.  
  28. //*************************************************************************
  29. //—————————————————————————————————————————————————————————————————————————
  30. class ListNode : public Object
  31. {
  32.     ListNode*        fNextNode;            
  33.     ListNode*        fPrevNode;
  34.     Object*            fNodeObject;
  35.     
  36. public:
  37.                         ListNode( Object* pObject );
  38. virtual                    ~ListNode(void);
  39.  
  40.         void            SetNext( ListNode* pNode ) { fNextNode = pNode; }    
  41.         void            SetPrev( ListNode* pNode ) { fPrevNode = pNode; }    
  42.         ListNode*        GetNext(void) { return fNextNode; }    
  43.         ListNode*        GetPrev(void) { return fPrevNode; }    
  44. virtual    Object*            GetNodeObject(void) { return fNodeObject; }    
  45. };
  46.  
  47. //*************************************************************************
  48. //—————————————————————————————————————————————————————————————————————————
  49. class List : public Object
  50. {
  51. protected:
  52.     ListNode*    fFirstNode;
  53.     ListNode*    fLastNode;
  54.     short        fCount;
  55.     
  56. public:                //——————————————————————————————————————————
  57.                         List(void);
  58. virtual                    ~List(void);
  59.  
  60.         short            Count(void){ return fCount; }
  61.         void            AddAsFirst( Object* pObject );
  62.         void            AddAsLast( Object* pObject );
  63.         void            Insert( Object* pObject, short pIndex );
  64.         void            Remove( Object* pObject );                
  65.         void            RemoveAll(void);                
  66.         void            DisposeAll(void);                
  67.             
  68.         Object*            GetFirst(void);
  69.         Object*            GetIndexed( short pIndex );    
  70.         ListNode*        GetFirstNode(void) { return fFirstNode; }
  71.         short            GetIndexOf( Object* pObject );
  72.  
  73. private:            //——————————————————————————————————————————
  74.         ListNode*        FindNode( Object* pObject );
  75. };
  76.             
  77. //*************************************************************************
  78. //—————————————————————————————————————————————————————————————————————————
  79. class Loop : public Object
  80. {
  81.     List*        fList;
  82.     ListNode*    fCurrNode;
  83. public:    
  84.                         Loop( List* pList );
  85. virtual                    ~Loop(void);
  86.         void            Reset( List* pList );
  87.         Object*            GetNext(void);
  88. };
  89.  
  90. #endif
  91.